package cn.donting.jme.edit.ui.scenetree;

import com.jme3.scene.Spatial;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

/**
 * 剪切板
 */

public class ClipBoard {

    @Getter
    private Spatial copy;
    @Getter
    private SpatialTreeItem cut;

    @Getter
    private SceneTreeNodeView sceneTreeNodeView;

    private static ClipBoard clipBoard;

    public static ClipBoard getInstance() {
        return clipBoard;
    }

    public ClipBoard(SceneTreeNodeView sceneTreeNodeView) {
        this.sceneTreeNodeView = sceneTreeNodeView;
        clipBoard = this;
    }

    /**
     * 获取选中的Spatial
     *
     * @return
     */
    public Spatial getSelectSpatial() {
        SpatialTreeItem selectedItem = (SpatialTreeItem) sceneTreeNodeView.treeView.getSelectionModel().getSelectedItem();
        if(selectedItem==null){
            return null;
        }
        return selectedItem.getSpatial();
    }

    public SpatialTreeItem getSelectSpatialTreeItem() {
        SpatialTreeItem selectedItem = (SpatialTreeItem) sceneTreeNodeView.treeView.getSelectionModel().getSelectedItem();
        return selectedItem;
    }

    public void setCopy(Spatial copy) {
        this.copy = copy;
        this.cut = null;
    }

    public void setCut(SpatialTreeItem cut) {
        this.cut = cut;
        this.copy = null;
    }
}
